package com.cq.xjms.model;

import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 * 课程实体类
 * @author caiqiang
 * @version 1
 */
@Entity
@Table(name="Course")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQueries( {
	@NamedQuery(name = "Course.query", query ="select c from Course c where  c.code=:code"),
	@NamedQuery(name = "Course.list", query ="select c from Course c order by c.id"),
	@NamedQuery(name = "Course.queryById", query ="select c from Course c  where c.id=:id"),
	@NamedQuery(name = "Course.queryByName", query ="select c from Course c  where c.name =:courseName"),
	@NamedQuery(name = "Course.queryByStatus", query ="select c from Course c  where c.status=:status"),

})
public class Course extends BaseEntity
{
	private static final long serialVersionUID = 1539350453366775796L;
	public static final String COURSE_QUERY="Course.query";
	public static final String COURSE_LIST="Course.list";
	public static final String COURSE_QUERYBYID="Course.queryById";
	public static final String COURSE_QUERYBYNAME="Course.queryByName";
	public static final String COURSE_QUERYBYSTATUS="Course.queryByStatus";
	
	@Column(name ="NAME",length=20,nullable = false)
	private String name;
	
	@Column(name="CODE",length=10)
	private String code ;

	@Column(name="STATUS",length=10)
	private int status;
//	@ManyToMany(mappedBy = "courses",fetch = FetchType.LAZY)
//	private List<Student> students;
//	
	@ManyToOne(fetch = FetchType.LAZY)
	private Teacher teacher;
	
	@Column(name ="CREDIT", length=10)
	private double credit ; //学分
	
	@Column(name = "TERM",length=50)
	private String term;
    
	@Column(name = "CREATEDATE", nullable = false)
	@Temporal(TemporalType.TIMESTAMP)
	private Date createDate=new Date();
	
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getCode() {
		return code;
	}

	public void setCode(String code) {
		this.code = code;
	}


//	public List<Student> getStudents() {
//		return students;
//	}
//
//	public void setStudents(List<Student> students) {
//		this.students = students;
//	}


	public double getCredit() {
		return credit;
	}

	public void setCredit(double credit) {
		this.credit = credit;
	}

	public String getTerm() {
		return term;
	}

	public void setTerm(String term) {
		this.term = term;
	}

	public Teacher getTeacher() {
		return teacher;
	}

	public void setTeacher(Teacher teacher) {
		this.teacher = teacher;
	}

	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public int getStatus() {
		return status;
	}

	public void setStatus(int status) {
		this.status = status;
	}

	
	
	
}
